<%--
  Created by IntelliJ IDEA.
  User: lb
  Date: 15-11-27
  Time: 上午11:17
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

<html>
<head>
    <title>管理员查看所有订单</title>
    <script src="/static/bootstrap/js/bootstrap-paginator.js"></script>
    <script>
        $(function () {
            var totalPage = $("#totalPage").val();
            var currentPage = $("#currentPage").val();
            var options = {
                bootstrapMajorVersion: 3,
                currentPage: currentPage,
                totalPages: totalPage,
                size: "normal",
                alignment: "center",
                itemTexts: function (type, page, current) {
                    switch (type) {
                        case "first":
                            return "首页";
                        case "prev":
                            return "上一页";
                        case "next":
                            return "下一页";
                        case "last":
                            return "末页";
                        case "page":
                            return page;
                    }
                },
                onPageClicked: function (e, originalEvent, type, page) {
                    window.location.href = '/orderback/order_list/' + page;
                }
            }
            $("#pager").bootstrapPaginator(options);
        });

        function searchOrderInfo() {
            var phoneNum = $("#phoneNum").val();
            $.ajax({
                url: '/orderback/search',
                type: 'post',
                dataType: 'json',
                data: {phoneNum: phoneNum},
                success: function (data) {
                    $("table tbody").html(data);
                }
            })
        }
    </script>
</head>
<body>
<input type="text" id="phoneNum" placeholder="电话号码" />&nbsp;
<button type="button" class="btn btn-warning" onclick="searchOrderInfo()">订单搜索</button>
<table class="table table-striped">
    <thead>
    <th>房屋</th>
    <th>周次</th>
    <th>价格</th>
    <th>区域</th>
    <th>用户姓名</th>
    <th>用户电话</th>
    <th>支付状态</th>
    <th>时间</th>
    <th>交易流水号</th>
    </thead>
    <tbody>
    <c:forEach items="${orderDTOs}" var="orderDTO">
        <tr>
            <td>${orderDTO.houseInfoDTO.name}</td>
            <td>${orderDTO.houseWeekDTO.name}</td>
            <td>￥${orderDTO.houseWeekDTO.price}</td>
            <td>${orderDTO.houseWeekDTO.houseBaseArea}</td>
            <td>${orderDTO.realName}</td>
            <td>${orderDTO.phoneNum}</td>
            <td>${orderDTO.orderInfoDTO.status}</td>
            <td>${orderDTO.orderInfoDTO.time}</td>
            <c:choose>
                <c:when test="${orderDTO.orderInfoDTO.alipayTradeNo==null}">
                    <td>无数据</td>
                </c:when>
                <c:otherwise>
                    <td>${orderDTO.orderInfoDTO.alipayTradeNo}</td>
                </c:otherwise>
            </c:choose>
        </tr>
    </c:forEach>
    </tbody>
</table>
<div style="text-align: center;">
    <input type="hidden" id="totalPage" value="${totalPage}">
    <input type="hidden" id="currentPage" value="${currentPage}">
    <ul id="pager"></ul>
</div>
</body>
</html>